package cn.com.homeyoda.aimate.aihealth.utils;

import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.airbnb.lottie.LottieAnimationView;
import com.airbnb.lottie.LottieDrawable;
import com.bumptech.glide.Glide;

import cn.com.homeyoda.aimate.aihealth.R;


/**
 * Created By 刘纯贵
 * Created Time 2020/6/3
 */
public class ShowIsAuthDialog {
    private  Context mContext;
    private  Dialog dialog;
    private  View inflate;
    private  TextView textView;
    private ImageView linajie;
    private ImageView kefu;
    private RelativeLayout relativeLayout;


    public   ShowIsAuthDialog(Context context,String message,String lianjieUrl,String kefuUrl){
        //mContext = context;
        if(dialog == null){
            dialog = new Dialog(context, R.style.FullScreenDialog);
            inflate = LayoutInflater.from(context).inflate(R.layout.layout_isauth, null);
            dialog.setContentView(inflate);
            dialog.setCanceledOnTouchOutside(true);
            linajie = inflate.findViewById(R.id.lianjie);
            kefu = inflate.findViewById(R.id.kefu);
            relativeLayout = inflate.findViewById(R.id.bg);
            Glide.with(context)
                    .load(lianjieUrl)
                    .into(linajie);
            Glide.with(context)
                    .load(kefuUrl)
                    .into(kefu);
            textView = dialog.findViewById(R.id.text);
            textView.setText(message);
            relativeLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dismiss();
                }
            });
//        loadingView = inflate.findViewById(R.id.loadView);
//        loadingView.setLoadingText("加载中...");
//            Window dialogWindow = dialog.getWindow();
//            dialogWindow.setGravity( Gravity.CENTER_VERTICAL);
//            WindowManager.LayoutParams lp = dialogWindow.getAttributes();
//
//            dialogWindow.setAttributes(lp);
        }




    }



    public void Show(){
        dialog.show();
    }

    public  void dismiss(){
        if (dialog != null && dialog.isShowing()) {
            Log.i("huahua","dialog.==dismiss==");
            dialog.dismiss();
            dialog = null;
        }
    }
}
